// import { PageInterface, ProxyResponse } from '../model'
// import { ProxyCRUD } from '../service-crud/proxy-service'
// import { ProxyController } from './proxyControllerService'

// export class ProxyControllerImpl<T> implements ProxyController<T>{

//     constructor(
//         protected client: ProxyCRUD<T>,
//         protected size: number,
//         protected lengthPage: number
//     ) { }
//     //50 6 10
//     calShowPage(totalData: number, nowPage: number, lengthPage: number): PageInterface {

//         const start = Number((nowPage - 1)) * Number(this.size)
//         const end = Number(this.size) * Number(nowPage)
//         //计算总页数
//         const pageFlag = totalData % Number(this.size)
//         const totalPage = pageFlag == 0 ? totalData / Number(this.size) : Math.ceil(totalData / Number(this.size))
//         if (totalPage < lengthPage) lengthPage = totalPage
//         const diffNumber: number = lengthPage % 2 == 0 ? (lengthPage / 2) : (lengthPage / 2) - 1
//         const maxPageNumber: number = (totalPage + (totalPage - lengthPage)) + 1
//         const minPageNumber: number = lengthPage + 1
//         const leftNumber: number = Number(nowPage) - Number(diffNumber)
//         const rightNumber: number = Number(nowPage) + Number(diffNumber)
//         const sum: number = Number(leftNumber) + Number(rightNumber)
//         if (maxPageNumber < sum) return { totalPage: totalPage, startSilce: start, endSilce: end, startPage: leftNumber, endPage: totalPage }
//         if (minPageNumber > sum) return { totalPage: totalPage, startSilce: start, endSilce: end, startPage: 1, endPage: lengthPage }

//         return { totalPage: Math.ceil(totalPage), startSilce: start, endSilce: end, startPage: leftNumber, endPage: rightNumber }
//     }


//     async findByParams(condition: any, nowPage: number): Promise<ProxyResponse<T>> {
//         const res = await this.client.findByParams(condition)
//         const { totalPage, startSilce, endSilce, startPage, endPage } = this.calShowPage(res.length, nowPage, this.lengthPage)
//         const list = res.slice(startSilce, endSilce)
//         const responseData: ProxyResponse<T> = {
//             data: list,
//             pageTotal: totalPage,
//             currentPage: nowPage,
//             startPage: startPage,
//             endPage: endPage
//         }
//         return responseData
//     }

//     async findAll(nowPage: number): Promise<ProxyResponse<T>> {
//         const res = await this.client.findAll()
//         const { totalPage, startSilce, endSilce, startPage, endPage } = this.calShowPage(res.length, nowPage, this.lengthPage)
//         //分页
//         const list = res.slice(startSilce, endSilce)

//         const responseData: ProxyResponse<T> = {
//             data: list,
//             pageTotal: totalPage,
//             currentPage: nowPage,
//             startPage: startPage,
//             endPage: endPage
//         }
//         return responseData
//     }
// }